﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;

namespace BusinessObjects
{
    public class Project
    {
        public Guid ProjectId { get; set; }
        public Guid OfficerId { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }

        public Person Officer { get; set; }
        public List<Risk> Risks { get; set; }

        /// <summary>
        /// Возвращает список всех проектов.
        /// </summary>
        /// <returns></returns>
        public List<Project> Retrieve()
        {
            try
            {
                RiskManagementContext сontext = new RiskManagementContext();
                var query = from c in сontext.Projects.Include("Risks").Include("Officer") select c;
                return query.ToList();
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Error in Project Retrieve - " + ex.Message, ex);
            }
        }
    }
}
